package cn.wetcland.urban.admin.controller;

import cn.wetcland.urban.admin.dto.OrderUpdateDTO;
import cn.wetcland.urban.admin.service.UtOrderService;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.generator.domain.UtCustomer;
import cn.wetcland.urban.generator.domain.UtOrder;
import cn.wetcland.urban.generator.dto.BaseConditionSearchDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    public UtOrderService orderService;

    @GetMapping("/orderList")
    public AjaxResponse orderList(BaseConditionSearchDTO searchDTO) {
        Page<UtOrder> orderPage = orderService.orderList(searchDTO);
        return AjaxResponse.success(orderPage);
    }

    @PutMapping("/orderUpdate")
    public AjaxResponse orderUpdate(@RequestBody OrderUpdateDTO updateDTO) {
        orderService.orderUpdate(updateDTO);
        return AjaxResponse.success();
    }

    @DeleteMapping("/orderDelete/{orderId}")
    public AjaxResponse orderDelete(@PathVariable Long orderId) {
        orderService.orderDelete(orderId);
        return AjaxResponse.success();
    }

}
